package com.atguigu04.compare.comparable;

import com.atguigu04.compare.Product;
import org.junit.Test;

import java.util.Arrays;

/**
 * ClassName: ComparableTest
 * Package: com.atguigu04.compare.comparable
 * Description:
 *
 * @Author ZY
 * @Create 13:49
 * @Version 1.0
 */
public class ComparableTest {

    @Test
    public void test1(){
        String[] arr = new String[]{"Tom","Jerry","Tony","Rose","Jack","Lucy"};

        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    @Test
    public void test2(){
        Product[] arr = new Product[5];
        arr[0] = new Product("HuaWei",6999);
        arr[1] = new Product("Xiaomi13",4999);
        arr[2] = new Product("Iphone",8999);
        arr[3] = new Product("Oppo",5999);
        arr[4] = new Product("Redmi",2999);

        Arrays.sort(arr);
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}
